package com.lingjtx.common.influx.client;

import com.lingjtx.common.influx.ql.QLRequest;
import com.lingjtx.common.influx.ql.QLResponse;
import com.lingjtx.common.other.annotation.*;
import com.lingjtx.common.other.http.Call;
import com.lingjtx.common.other.http.ResponseType;

public interface InfluxClientApi {

    // =============== influxDB 执行语句 http api  ==================
    @Headers({
            "Content-Type: text/plain; charset=utf-8",
            "Accept: application/json",
    })
    @POST("/api/v2/write")
    Call<String> influxWrite(
            @BaseUrl String baseUrl,
            @Header("Authorization") String token,
            @Query("org") String org,
            @Query("bucket") String bucket,
            @Query("precision") String precision,
            @Body String body);


    @Headers({
            "Content-Type: application/vnd.flux",
            "Accept: application/json",
    })
    @POST("/api/v2/query")
    @ResponseFormat(ResponseType.STRING)
    Call<String> influxQueryFlux(
            @BaseUrl String baseUrl,
            @Header("Authorization") String token,
            @Query("org") String org,
            @Body String body);

    @POST("/query")
    Call<QLResponse> influxQL(
            @BaseUrl String baseUrl,
            @Header("Authorization") String token,
            @Query("org") String org,
            @QueryObject QLRequest request);
}
